package com.zhoug.zmui.dialog;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.Gravity;
import android.view.WindowManager;
import android.widget.Toast;

import com.zhoug.common.utils.AppUtils;
import com.zhoug.common.utils.LogUtils;
import com.zhoug.common.utils.StringUtils;
import com.zhoug.zmui.R;
import com.zhoug.zmui.ZMUIAnimations;
import com.zhoug.zmui.dialog.list.ZMUIListDialog;
import com.zhoug.zmui.ints.OnItemClickListener;
import com.zhoug.zmui.utils.ZMUIMapSdkManager;

import java.util.Arrays;
import java.util.List;

public class MapSdkDialog {
    private static final String TAG = ">>>MapSdkManager";
    private Context context;
    private ZMUIListDialog<String> listDialog;
    private List<String> maps = Arrays.asList("百度地图", "高德地图", "腾讯地图");
    private ZMUIMapSdkManager mapSdkManager;

    public MapSdkDialog(Context context) {
        this.context = context;
        mapSdkManager = new ZMUIMapSdkManager(context);
        init();
    }

    private void init() {
        listDialog = new ZMUIListDialog<String>(context) {
            @Override
            public String getText(String itemData) {
                return itemData;
            }
        };
        listDialog.setAttributes(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
        listDialog.setWindowAnimations(ZMUIAnimations.ANIM_DOWN);
        listDialog.setCanceledOnTouchOutside(true);
        listDialog.setData(maps);
        listDialog.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                switch (position) {
                    case 0:
                        mapSdkManager.toBaiduMapRoutePlanning();
                        break;
                    case 1:
                        mapSdkManager.toGaodeMapRoutePlanning();
                        break;
                    case 2:
                        mapSdkManager.toTencentMapRoutePlanning();
                        break;
                }
            }
        });
    }

    public void show() {
        listDialog.show();
    }

    /**
     * 设置终点经纬度
     *
     * @param targetLatitude  终点维度
     * @param targetLongitude 终点经度
     */
    public void setTargetLocation(double targetLatitude, double targetLongitude) {
        mapSdkManager.setTargetLocation(targetLatitude, targetLongitude);
    }

    /**
     * 设置终点地址
     *
     * @param targetAddress
     */
    public void setTargetAddress(String targetAddress) {
        mapSdkManager.setTargetAddress(targetAddress);
    }


    public void setCoordType(String coordType) {
        mapSdkManager.setCoordType(coordType);
    }

    public String getCoordType() {
        return mapSdkManager.getCoordType();
    }

    /**
     * 地址终点地名
     *
     * @param targetName
     */
    public void setTargetName(String targetName) {
        mapSdkManager.setTargetName(targetName);
    }

}
